Flexible Test ^^^^^ **Definition:** * Test code verifies different functionality depending on when or where it is run. **Code Example:** .. code-block:: java public void testDisplayCurrentTime_whenever() { // fixture setup TimeDisplay sut = new TimeDisplay(); // exercise SUT String result = sut.getCurrentTimeAsHtmlFragment(); // verify outcome Calendar time = new DefaultTimeProvider().getTime(); StringBuffer expectedTime = new StringBuffer(); expectedTime.append(""); if ((time.get(Calendar.HOUR_OF_DAY) == 0) && (time.get(Calendar.MINUTE) <= 1)) { expectedTime.append( "Midnight"); } else if ((time.get(Calendar.HOUR_OF_DAY) == 12) && (time.get(Calendar.MINUTE) == 0)) { // noon expectedTime.append("Noon"); } else { SimpleDateFormat fr = new SimpleDateFormat("h:mm a"); expectedTime.append(fr.format(time.getTime())); } expectedTime.append(""); assertEquals( expectedTime, result); } **References:** .. admonition:: Quality attributes * :octicon:`file-code;1em` - Code Example * :octicon:`comment-discussion;1em` - Cause and Effect * :octicon:`graph;1em` - Frequency * :octicon:`sync;1em` - Refactoring * `xUnit test patterns: Refactoring test code `_ :octicon:`file-code;1em` :octicon:`comment-discussion;1em` :octicon:`sync;1em`